{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "d3676841",
   "metadata": {},
   "source": [
    "# 第九周\n",
    " > 1.while循环\n",
    " \n",
    " > 2.购物车的练习\n",
    " \n",
    " > 3.元组_集合"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "42a90823",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "张智豪王八蛋 0\n",
      "张智豪王八蛋 1\n",
      "张智豪王八蛋 2\n",
      "张智豪王八蛋 3\n",
      "张智豪王八蛋 4\n",
      "张智豪王八蛋 5\n",
      "张智豪王八蛋 6\n",
      "张智豪王八蛋 7\n",
      "张智豪王八蛋 8\n",
      "张智豪王八蛋 9\n",
      "张智豪王八蛋 10\n",
      "张智豪王八蛋 11\n",
      "张智豪王八蛋 12\n",
      "张智豪王八蛋 13\n",
      "张智豪王八蛋 14\n",
      "张智豪王八蛋 15\n",
      "张智豪王八蛋 16\n",
      "张智豪王八蛋 17\n",
      "张智豪王八蛋 18\n",
      "张智豪王八蛋 19\n",
      "张智豪王八蛋 20\n",
      "张智豪王八蛋 21\n",
      "张智豪王八蛋 22\n",
      "张智豪王八蛋 23\n",
      "张智豪王八蛋 24\n",
      "张智豪王八蛋 25\n",
      "张智豪王八蛋 26\n",
      "张智豪王八蛋 27\n",
      "张智豪王八蛋 28\n",
      "张智豪王八蛋 29\n",
      "张智豪王八蛋 30\n",
      "张智豪王八蛋 31\n",
      "张智豪王八蛋 32\n",
      "张智豪王八蛋 33\n",
      "张智豪王八蛋 34\n",
      "张智豪王八蛋 35\n",
      "张智豪王八蛋 36\n",
      "张智豪王八蛋 37\n",
      "张智豪王八蛋 38\n",
      "张智豪王八蛋 39\n",
      "张智豪王八蛋 40\n",
      "张智豪王八蛋 41\n",
      "张智豪王八蛋 42\n",
      "张智豪王八蛋 43\n",
      "张智豪王八蛋 44\n",
      "张智豪王八蛋 45\n",
      "张智豪王八蛋 46\n",
      "张智豪王八蛋 47\n",
      "张智豪王八蛋 48\n",
      "张智豪王八蛋 49\n",
      "张智豪王八蛋 50\n",
      "张智豪王八蛋 51\n",
      "张智豪王八蛋 52\n",
      "张智豪王八蛋 53\n",
      "张智豪王八蛋 54\n",
      "张智豪王八蛋 55\n",
      "张智豪王八蛋 56\n",
      "张智豪王八蛋 57\n",
      "张智豪王八蛋 58\n",
      "张智豪王八蛋 59\n",
      "张智豪王八蛋 60\n",
      "张智豪王八蛋 61\n",
      "张智豪王八蛋 62\n",
      "张智豪王八蛋 63\n",
      "张智豪王八蛋 64\n",
      "张智豪王八蛋 65\n",
      "张智豪王八蛋 66\n",
      "张智豪王八蛋 67\n",
      "张智豪王八蛋 68\n",
      "张智豪王八蛋 69\n",
      "张智豪王八蛋 70\n",
      "张智豪王八蛋 71\n",
      "张智豪王八蛋 72\n",
      "张智豪王八蛋 73\n",
      "张智豪王八蛋 74\n",
      "张智豪王八蛋 75\n",
      "张智豪王八蛋 76\n",
      "张智豪王八蛋 77\n",
      "张智豪王八蛋 78\n",
      "张智豪王八蛋 79\n",
      "张智豪王八蛋 80\n",
      "张智豪王八蛋 81\n",
      "张智豪王八蛋 82\n",
      "张智豪王八蛋 83\n",
      "张智豪王八蛋 84\n",
      "张智豪王八蛋 85\n",
      "张智豪王八蛋 86\n",
      "张智豪王八蛋 87\n",
      "张智豪王八蛋 88\n",
      "张智豪王八蛋 89\n",
      "张智豪王八蛋 90\n",
      "张智豪王八蛋 91\n",
      "张智豪王八蛋 92\n",
      "张智豪王八蛋 93\n",
      "张智豪王八蛋 94\n",
      "张智豪王八蛋 95\n",
      "张智豪王八蛋 96\n",
      "张智豪王八蛋 97\n",
      "张智豪王八蛋 98\n",
      "张智豪王八蛋 99\n"
     ]
    }
   ],
   "source": [
    "count = 0\n",
    "while True:\n",
    "    print(\"张智豪王八蛋\",count) # 只到这里会无线循环\n",
    "    count +=1\n",
    "    if count ==100: # 设置循环次数\n",
    "        break # 打断、终止"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "731ec71c",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "hide_card:27\n"
     ]
    }
   ],
   "source": [
    "# 猜数字小游戏： 0<n<100,5次机会猜数字，每次猜完，出题人告诉提示你（猜的有点大/有点小）\n",
    "\n",
    "hide_card = int(input(\"hide_card:\")) # 出题人\n",
    "count = 0"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "1606784a",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "游戏开始\n",
      "guess_dieit:21\n",
      "往大了猜！怂啥。。\n",
      "guess_dieit:30\n",
      "太大了，猜小点。。\n",
      "guess_dieit:28\n",
      "太大了，猜小点。。\n",
      "guess_dieit:26\n",
      "往大了猜！怂啥。。\n",
      "guess_dieit:27\n",
      "算你蒙对了\n"
     ]
    }
   ],
   "source": [
    "if hide_card<100 and hide_card>0:\n",
    "    print(\"游戏开始\")\n",
    "    while True:\n",
    "        if count<5:\n",
    "            # 猜题人要填的数字为guess_digit\n",
    "            guess_digit  = int(input(\"guess_dieit:\")) # 玩游戏的人 ，int()用来将字符串数字化\n",
    "            if guess_digit == hide_card: # 如果猜的人填的数等于出题人的数字\n",
    "                print(\"算你蒙对了\")\n",
    "                break # 输入正确，停止\n",
    "            elif guess_digit>hide_card: # 如果猜的太大\n",
    "                print(\"太大了，猜小点。。\")\n",
    "            else:\n",
    "                print(\"往大了猜！怂啥。。\")\n",
    "            count=count+1\n",
    "        else:\n",
    "            print(\"那么多次还不对？干什么吃的。。\")\n",
    "            print(\"正确答案是：%s\"%hide_card)\n",
    "            break # 机会用尽，停止\n",
    "else:\n",
    "    print(\"李在赣神魔，看游戏规则没？？\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "06c98909",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
